#!/bin/bash

# 停止并禁用 rpcbind 服务
systemctl stop rpcbind 2>/dev/null
systemctl disable rpcbind 2>/dev/null

# 卸载 rpcbind 包（兼容 dnf/yum/apt）
if command -v dnf >/dev/null 2>&1; then
    dnf remove -y rpcbind 2>/dev/null
elif command -v yum >/dev/null 2>&1; then
    yum remove -y rpcbind 2>/dev/null
elif command -v apt-get >/dev/null 2>&1; then
    apt-get purge -y rpcbind 2>/dev/null
fi

# 验证
if rpm -qa 2>/dev/null | grep -q '^rpcbind' || dpkg -l 2>/dev/null | grep -q 'rpcbind'; then
    echo "[-] rpcbind 包仍然存在"
    exit 1
else
    echo "[+] rpcbind 服务及相关包已卸载"
    exit 0
fi